import { Controller, Post, Body, Get } from '@nestjs/common';
import { YijingService } from './yijing.service';
import type { DivinationRequest, DivinationResponse, CoinDivinationRequest } from './yijing.types';

@Controller('yijing')
export class YijingController {
  constructor(private readonly yijingService: YijingService) {}

  @Post('divination')
  async createDivination(
    @Body() request: DivinationRequest
  ): Promise<DivinationResponse> {
    return this.yijingService.generateGuaXiang(request.numbers, request.question);
  }

  @Post('random')
  async getRandomDivination(): Promise<DivinationResponse> {
    return this.yijingService.generateRandomGua();
  }

  @Post('coin')
  async generateCoinGua(@Body() request: CoinDivinationRequest): Promise<DivinationResponse> {
    return this.yijingService.generateCoinGua(request.question);
  }

  @Get('health')
  async healthCheck(): Promise<{ status: string }> {
    return { status: 'OK' };
  }
}